package com.ptone.messagecenter.common.base;


public class Tuple2<A, B> {

    private final A _1;
    private final B _2;

    public Tuple2(A _1, B _2) {
        this._1 = _1;
        this._2 = _2;
    }

    public Boolean leftIsNull() {
        return _1 == null;
    }

    public Boolean rightIsNull() {
        return _2 == null;
    }

    public Boolean leftNotNull() {
        return _1 != null;
    }

    public Boolean rightNotNull() {
        return _2 != null;
    }

    public A left() {
        return _1;
    }

    public B right() {
        return _2;
    }


    public static <A, B> Tuple2<A, B> left(A a) {
        return new Tuple2(a, null);
    }

    public static <A, B> Tuple2<A, B> right(B b) {
        return new Tuple2(null, b);
    }

    public String toString() {
        return "Tuple2(_1: " + this._1 + ", _2: " + this._2 + ")";
    }

}
